package com.iskny.framework.admin.interceptor;

import com.iskny.framework.model.LoginResult;
import com.iskny.framework.session.UserSession;
import com.jfinal.aop.Interceptor;
import com.jfinal.core.ActionInvocation;
import com.jfinal.core.Controller;

public class LoginInterceptor implements Interceptor {

	public LoginInterceptor(){
	}
	@Override
	public void intercept(ActionInvocation ai) {
		Controller c = ai.getController();
		UserSession u = new UserSession(c.getSession());
		LoginResult r = u.isValidate();
		if(r==LoginResult.success){
			ai.invoke();
			return;
		}else{
			c.redirect("/admin/login");
		}
	}

}
